<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
  <!-- <script src="https://cdn.jsdelivr.net/npm/vue@2/dist/vue.js"></script> -->
  <script src="./node_modules/vue/dist/vue.js"></script>
</head>

<body>
  <div id="app">
    {{ count>5 ? count : "小于5"}}
    <button v-on:click.once="count++">按钮</button>
    <button v-on:click="handleChange(5)">按钮</button>
    <form @submit.prevent="handlePrevent">
      <button>提交</button>
    </form>
  </div>

  <script>
    // v-on 绑定事件  值可以是函数也可以是表达式
    // 对应的方法都放到methods属性中
    // v-on 简写是 @click
    // 修饰符
    const app = new Vue({
      el: "#app",
      data: {
        count: 0,
      },
      methods: {
        handleChange(val) {
          this.count += val
        },
        handlePrevent() {
          console.log("阻止提交")
        }

      }
    })
  </script>

</body>

</html>
